﻿using BW.MesProject.Public.ErrorCode;
using BW.MesProject.WareHouse.Application;
using BW.MesProject.WareHouse.Domain;
using BW.MesProject.WareHouse.Infrastructure;
using BW.MesProject.WareHouse.Infrastructure.Dto.Input;
using BW.MesProject.WareHouse.Infrastructure.Dto.OutPut;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.MesProject.WareHouse.Host.Controllers
{
    /// <summary>
    /// 外部标签解析
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LabelController : ControllerBase
    {
        // GET: api/<LabelController>
        private readonly ILabelServices LabelServices;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="LabelServices"></param>
        public LabelController(ILabelServices LabelServices)
        {
            this.LabelServices = LabelServices;
        }
        /// <summary>
        /// 添加外部标签解析
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddLabel(LabelModel model)
        {
            return LabelServices.AddLabel(model);
        }
        /// <summary>
        /// 删除外部标签解析
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> DeleteLabel(long Id)
        {
            return LabelServices.DeleteLabel(Id);
        }
        /// <summary>
        /// 获取外部标签解析
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<LabelOut>> GetLabel([FromQuery] QryInput qryInput)
        {
            return LabelServices.GetLabel(qryInput);
        }
        /// <summary>
        /// 修改外部标签解析
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdatLabel(LabelModel model)
        {
            return LabelServices.UpdateLabel(model);
        }

        /// <summary>
        /// 修改启用
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateEnable(LabelModel model)
        {
            return LabelServices.UpdateEnable(model);
        }


        /// <summary>
        /// 软删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> UpdateDelete(long Id)
        {
            return LabelServices.UpdateDelete(Id);
        }

        /// <summary>
        /// 查询编码
        /// </summary>
        /// <param name="LabelID"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<int> GetLabelID(string LabelID)
        {
            return LabelServices.GetLabelID(LabelID);
        }
    }
}
